package com.wxy.demo.controller;

import cn.hutool.core.io.FileUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

/**
 * <p>
 * 文件上传测试
 * </p>
 *
 * @author e-Xiaoyuan.Wang
 * @since 2022/12/6 10:10
 */
@RestController
@RequestMapping("file")
public class FileController {

    @GetMapping("download")
    public void download(HttpServletResponse response) throws IOException {
        String text = """
                {"appId":"Blspqr2JnxldUPDmmJIrtznpOGhiOB5OwO0CRufGBPg=","appName":"自动化测试平台-部署测试","content":"{\\"activeUser\\":{\\"activeUserRange\\":{\\"活跃天数0~3天\\":3,\\"活跃天数4~5天\\":0,\\"活跃天数6~7天\\":0},\\"totalUser\\":3},\\"endpointViews\\":[{\\"endpoint\\":\\"#/workbench/setDS?id=15\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":2,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/setDS\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":4,\\"uv\\":2},{\\"endpoint\\":\\"#/workbench/portCase?id=15\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/portCase?id=55\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":4,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/portCase\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/productSet/basic\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":5,\\"uv\\":2},{\\"endpoint\\":\\"#/workbench/useCase/frameCase\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":3,\\"uv\\":2},{\\"endpoint\\":\\"#/workbench/useCase/menu\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":3,\\"uv\\":2},{\\"endpoint\\":\\"#/workbench/environment\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/auto/ripe\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/accueil\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":2,\\"uv\\":2},{\\"endpoint\\":\\"#/accueil/product?code=virtual-095b7cb4-5394-4490-8b65-63bfa5f23494\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/accueil/product?code=virtual-487af2bf-dc42-4cc4-bb8f-b92af9e54457\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/accueil/product\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":6,\\"uv\\":3},{\\"endpoint\\":\\"#/accueil?code=virtual-487af2bf-dc42-4cc4-bb8f-b92af9e54457\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/accueil?code=virtual-095b7cb4-5394-4490-8b65-63bfa5f23494\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/admin/config\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":2,\\"uv\\":1},{\\"endpoint\\":\\"#/admin/center?code=virtual-fe9fdd71-eabc-4ec3-b2d3-a7c9d865c95c\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":2,\\"uv\\":1},{\\"endpoint\\":\\"#/admin/center\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1}],\\"feedbacks\\":[{\\"contact\\":\\"\\",\\"content\\":\\"哎哟不错哟,\\",\\"endpoint\\":\\"#/accueil/product\\",\\"feedbackTime\\":1670232261000}],\\"onlineTimeAvg\\":{\\"avgOnlineTime\\":92286,\\"endTime\\":1670342400000,\\"startTime\\":1669824000000,\\"totalDay\\":7},\\"pvUvTrend\\":{\\"avgPv\\":6.14,\\"avgUv\\":0.71,\\"endTime\\":1670342400000,\\"pvTrend\\":{\\"dates\\":[\\"2022-12-01\\",\\"2022-12-02\\",\\"2022-12-03\\",\\"2022-12-04\\",\\"2022-12-05\\",\\"2022-12-06\\",\\"2022-12-07\\"],\\"values\\":[0,9,0,0,15,5,14]},\\"startTime\\":1669824000000,\\"totalDay\\":7,\\"uvTrend\\":{\\"dates\\":[\\"2022-12-01\\",\\"2022-12-02\\",\\"2022-12-03\\",\\"2022-12-04\\",\\"2022-12-05\\",\\"2022-12-06\\",\\"2022-12-07\\"],\\"values\\":[0,0,0,0,3,1,1]}},\\"reportInfo\\":{\\"createTime\\":1670397297688,\\"reportName\\":\\"自动化测试平台-部署测试2022-12-07使用分析\\"},\\"userBehaviorViews\\":[{\\"activeDays\\":2,\\"behaviorPaths\\":[{\\"endpoint\\":\\"#/accueil/product?code=virtual-095b7cb4-5394-4490-8b65-63bfa5f23494\\",\\"events\\":[],\\"visitTime\\":1670221204000},{\\"endpoint\\":\\"#/accueil?code=virtual-095b7cb4-5394-4490-8b65-63bfa5f23494\\",\\"events\\":[],\\"visitTime\\":1670221204000},{\\"endpoint\\":\\"#/auto/ripe\\",\\"events\\":[],\\"visitTime\\":1670221757000},{\\"endpoint\\":\\"#/accueil?code=virtual-487af2bf-dc42-4cc4-bb8f-b92af9e54457\\",\\"events\\":[],\\"visitTime\\":1670377549000},{\\"endpoint\\":\\"#/accueil/product?code=virtual-487af2bf-dc42-4cc4-bb8f-b92af9e54457\\",\\"events\\":[],\\"visitTime\\":1670377549000},{\\"endpoint\\":\\"#/accueil/product\\",\\"events\\":[],\\"visitTime\\":1670377560000},{\\"endpoint\\":\\"#/workbench/portCase?id=15\\",\\"events\\":[],\\"visitTime\\":1670377560000},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":[],\\"visitTime\\":1670377562000},{\\"endpoint\\":\\"#/workbench/setDS\\",\\"events\\":[],\\"visitTime\\":1670377564000},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":[],\\"visitTime\\":1670377571000},{\\"endpoint\\":\\"#/workbench/portCase\\",\\"events\\":[],\\"visitTime\\":1670377573000},{\\"endpoint\\":\\"#/workbench/useCase/menu\\",\\"events\\":[],\\"visitTime\\":1670377576000},{\\"endpoint\\":\\"#/workbench/useCase/frameCase\\",\\"events\\":[],\\"visitTime\\":1670377577000},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":[],\\"visitTime\\":1670377581000},{\\"endpoint\\":\\"#/workbench/setDS\\",\\"events\\":[],\\"visitTime\\":1670377582000},{\\"endpoint\\":\\"#/workbench/setDS?id=15\\",\\"events\\":[],\\"visitTime\\":1670377602000}],\\"email\\":\\"Daixu.Wang@geely.com\\",\\"startVisitTime\\":1670221204000,\\"userId\\":\\"186432254635073536\\",\\"userName\\":\\"王代旭\\",\\"visitTotalPage\\":16,\\"visitTotalTime\\":606000},{\\"activeDays\\":1,\\"behaviorPaths\\":[{\\"endpoint\\":\\"#/accueil\\",\\"events\\":[],\\"visitTime\\":1670229887000},{\\"endpoint\\":\\"#/accueil/product\\",\\"events\\":[],\\"visitTime\\":1670229888000},{\\"endpoint\\":\\"#/workbench/portCase?id=55\\",\\"events\\":[],\\"visitTime\\":1670229893000},{\\"endpoint\\":\\"#/workbench/useCase/menu\\",\\"events\\":[],\\"visitTime\\":1670229896000},{\\"endpoint\\":\\"#/workbench/useCase/frameCase\\",\\"events\\":[],\\"visitTime\\":1670229899000},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":[],\\"visitTime\\":1670229901000},{\\"endpoint\\":\\"#/workbench/setDS\\",\\"events\\":[],\\"visitTime\\":1670229904000},{\\"endpoint\\":\\"#/workbench/environment\\",\\"events\\":[],\\"visitTime\\":1670229905000},{\\"endpoint\\":\\"#/workbench/productSet/basic\\",\\"events\\":[],\\"visitTime\\":1670229908000}],\\"email\\":\\"e-Xiaoyuan.Wang@geely.com\\",\\"startVisitTime\\":1670229887000,\\"userId\\":\\"186432655967051776\\",\\"userName\\":\\"王孝元\\",\\"visitTotalPage\\":9,\\"visitTotalTime\\":21000},{\\"activeDays\\":2,\\"behaviorPaths\\":[{\\"endpoint\\":\\"#/accueil\\",\\"events\\":[],\\"visitTime\\":1670232087000},{\\"endpoint\\":\\"#/accueil/product\\",\\"events\\":[],\\"visitTime\\":1670232088000},{\\"endpoint\\":\\"#/admin/config\\",\\"events\\":[],\\"visitTime\\":1670292486000},{\\"endpoint\\":\\"#/admin/center\\",\\"events\\":[],\\"visitTime\\":1670317919000},{\\"endpoint\\":\\"#/admin/center?code=virtual-fe9fdd71-eabc-4ec3-b2d3-a7c9d865c95c\\",\\"events\\":[],\\"visitTime\\":1670317937000}],\\"email\\":\\"Maojia.Wu@geely.com\\",\\"startVisitTime\\":1670232087000,\\"userId\\":\\"186432322490523648\\",\\"userName\\":\\"吴茂佳\\",\\"visitTotalPage\\":5,\\"visitTotalTime\\":19000}]}","createTime":1670397298000,"createUserId":"system","createUserName":"张卫星","endTime":1670342400000,"id":"1600388382668161026","reportName":"自动化测试平台-部署测试2022-12-07使用分析","serviceCnName":"自动化测试平台-部署测试","serviceId":"YXV0b3Rlc3QtZGVwbG95LXRlc3Q=.1","serviceName":"autotest-deploy-test","startTime":1669824000000}
                """;
        File file = new File("D://a.png");
        FileUtil.writeString(text, file, StandardCharsets.UTF_8);
        FileUtil.writeToStream(file, response.getOutputStream());
        response.addHeader("Content-Type", "application/octet-stream");
        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(file.getName(), StandardCharsets.UTF_8));
    }

    @GetMapping("download1")
    public void download1(HttpServletResponse response) throws IOException {
        String text = """
                EOF>>>>
                {"appId":"Blspqr2JnxldUPDmmJIrtznpOGhiOB5OwO0CRufGBPg=","appName":"自动化测试平台-部署测试","content":"{\\"activeUser\\":{\\"activeUserRange\\":{\\"活跃天数0~3天\\":3,\\"活跃天数4~5天\\":0,\\"活跃天数6~7天\\":0},\\"totalUser\\":3},\\"endpointViews\\":[{\\"endpoint\\":\\"#/workbench/setDS?id=15\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":2,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/setDS\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":4,\\"uv\\":2},{\\"endpoint\\":\\"#/workbench/portCase?id=15\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/portCase?id=55\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":4,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/portCase\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/productSet/basic\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":5,\\"uv\\":2},{\\"endpoint\\":\\"#/workbench/useCase/frameCase\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":3,\\"uv\\":2},{\\"endpoint\\":\\"#/workbench/useCase/menu\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":3,\\"uv\\":2},{\\"endpoint\\":\\"#/workbench/environment\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/auto/ripe\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/accueil\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":2,\\"uv\\":2},{\\"endpoint\\":\\"#/accueil/product?code=virtual-095b7cb4-5394-4490-8b65-63bfa5f23494\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/accueil/product?code=virtual-487af2bf-dc42-4cc4-bb8f-b92af9e54457\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/accueil/product\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":6,\\"uv\\":3},{\\"endpoint\\":\\"#/accueil?code=virtual-487af2bf-dc42-4cc4-bb8f-b92af9e54457\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/accueil?code=virtual-095b7cb4-5394-4490-8b65-63bfa5f23494\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1},{\\"endpoint\\":\\"#/admin/config\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":2,\\"uv\\":1},{\\"endpoint\\":\\"#/admin/center?code=virtual-fe9fdd71-eabc-4ec3-b2d3-a7c9d865c95c\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":2,\\"uv\\":1},{\\"endpoint\\":\\"#/admin/center\\",\\"events\\":{\\"eventCount\\":0,\\"eventDetails\\":[],\\"pvCount\\":0,\\"uvCount\\":0},\\"pv\\":1,\\"uv\\":1}],\\"feedbacks\\":[{\\"contact\\":\\"\\",\\"content\\":\\"哎哟不错哟,\\",\\"endpoint\\":\\"#/accueil/product\\",\\"feedbackTime\\":1670232261000}],\\"onlineTimeAvg\\":{\\"avgOnlineTime\\":92286,\\"endTime\\":1670342400000,\\"startTime\\":1669824000000,\\"totalDay\\":7},\\"pvUvTrend\\":{\\"avgPv\\":6.14,\\"avgUv\\":0.71,\\"endTime\\":1670342400000,\\"pvTrend\\":{\\"dates\\":[\\"2022-12-01\\",\\"2022-12-02\\",\\"2022-12-03\\",\\"2022-12-04\\",\\"2022-12-05\\",\\"2022-12-06\\",\\"2022-12-07\\"],\\"values\\":[0,9,0,0,15,5,14]},\\"startTime\\":1669824000000,\\"totalDay\\":7,\\"uvTrend\\":{\\"dates\\":[\\"2022-12-01\\",\\"2022-12-02\\",\\"2022-12-03\\",\\"2022-12-04\\",\\"2022-12-05\\",\\"2022-12-06\\",\\"2022-12-07\\"],\\"values\\":[0,0,0,0,3,1,1]}},\\"reportInfo\\":{\\"createTime\\":1670397297688,\\"reportName\\":\\"自动化测试平台-部署测试2022-12-07使用分析\\"},\\"userBehaviorViews\\":[{\\"activeDays\\":2,\\"behaviorPaths\\":[{\\"endpoint\\":\\"#/accueil/product?code=virtual-095b7cb4-5394-4490-8b65-63bfa5f23494\\",\\"events\\":[],\\"visitTime\\":1670221204000},{\\"endpoint\\":\\"#/accueil?code=virtual-095b7cb4-5394-4490-8b65-63bfa5f23494\\",\\"events\\":[],\\"visitTime\\":1670221204000},{\\"endpoint\\":\\"#/auto/ripe\\",\\"events\\":[],\\"visitTime\\":1670221757000},{\\"endpoint\\":\\"#/accueil?code=virtual-487af2bf-dc42-4cc4-bb8f-b92af9e54457\\",\\"events\\":[],\\"visitTime\\":1670377549000},{\\"endpoint\\":\\"#/accueil/product?code=virtual-487af2bf-dc42-4cc4-bb8f-b92af9e54457\\",\\"events\\":[],\\"visitTime\\":1670377549000},{\\"endpoint\\":\\"#/accueil/product\\",\\"events\\":[],\\"visitTime\\":1670377560000},{\\"endpoint\\":\\"#/workbench/portCase?id=15\\",\\"events\\":[],\\"visitTime\\":1670377560000},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":[],\\"visitTime\\":1670377562000},{\\"endpoint\\":\\"#/workbench/setDS\\",\\"events\\":[],\\"visitTime\\":1670377564000},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":[],\\"visitTime\\":1670377571000},{\\"endpoint\\":\\"#/workbench/portCase\\",\\"events\\":[],\\"visitTime\\":1670377573000},{\\"endpoint\\":\\"#/workbench/useCase/menu\\",\\"events\\":[],\\"visitTime\\":1670377576000},{\\"endpoint\\":\\"#/workbench/useCase/frameCase\\",\\"events\\":[],\\"visitTime\\":1670377577000},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":[],\\"visitTime\\":1670377581000},{\\"endpoint\\":\\"#/workbench/setDS\\",\\"events\\":[],\\"visitTime\\":1670377582000},{\\"endpoint\\":\\"#/workbench/setDS?id=15\\",\\"events\\":[],\\"visitTime\\":1670377602000}],\\"email\\":\\"Daixu.Wang@geely.com\\",\\"startVisitTime\\":1670221204000,\\"userId\\":\\"186432254635073536\\",\\"userName\\":\\"王代旭\\",\\"visitTotalPage\\":16,\\"visitTotalTime\\":606000},{\\"activeDays\\":1,\\"behaviorPaths\\":[{\\"endpoint\\":\\"#/accueil\\",\\"events\\":[],\\"visitTime\\":1670229887000},{\\"endpoint\\":\\"#/accueil/product\\",\\"events\\":[],\\"visitTime\\":1670229888000},{\\"endpoint\\":\\"#/workbench/portCase?id=55\\",\\"events\\":[],\\"visitTime\\":1670229893000},{\\"endpoint\\":\\"#/workbench/useCase/menu\\",\\"events\\":[],\\"visitTime\\":1670229896000},{\\"endpoint\\":\\"#/workbench/useCase/frameCase\\",\\"events\\":[],\\"visitTime\\":1670229899000},{\\"endpoint\\":\\"#/workbench/testPlan\\",\\"events\\":[],\\"visitTime\\":1670229901000},{\\"endpoint\\":\\"#/workbench/setDS\\",\\"events\\":[],\\"visitTime\\":1670229904000},{\\"endpoint\\":\\"#/workbench/environment\\",\\"events\\":[],\\"visitTime\\":1670229905000},{\\"endpoint\\":\\"#/workbench/productSet/basic\\",\\"events\\":[],\\"visitTime\\":1670229908000}],\\"email\\":\\"e-Xiaoyuan.Wang@geely.com\\",\\"startVisitTime\\":1670229887000,\\"userId\\":\\"186432655967051776\\",\\"userName\\":\\"王孝元\\",\\"visitTotalPage\\":9,\\"visitTotalTime\\":21000},{\\"activeDays\\":2,\\"behaviorPaths\\":[{\\"endpoint\\":\\"#/accueil\\",\\"events\\":[],\\"visitTime\\":1670232087000},{\\"endpoint\\":\\"#/accueil/product\\",\\"events\\":[],\\"visitTime\\":1670232088000},{\\"endpoint\\":\\"#/admin/config\\",\\"events\\":[],\\"visitTime\\":1670292486000},{\\"endpoint\\":\\"#/admin/center\\",\\"events\\":[],\\"visitTime\\":1670317919000},{\\"endpoint\\":\\"#/admin/center?code=virtual-fe9fdd71-eabc-4ec3-b2d3-a7c9d865c95c\\",\\"events\\":[],\\"visitTime\\":1670317937000}],\\"email\\":\\"Maojia.Wu@geely.com\\",\\"startVisitTime\\":1670232087000,\\"userId\\":\\"186432322490523648\\",\\"userName\\":\\"吴茂佳\\",\\"visitTotalPage\\":5,\\"visitTotalTime\\":19000}]}","createTime":1670397298000,"createUserId":"system","createUserName":"张卫星","endTime":1670342400000,"id":"1600388382668161026","reportName":"自动化测试平台-部署测试2022-12-07使用分析","serviceCnName":"自动化测试平台-部署测试","serviceId":"YXV0b3Rlc3QtZGVwbG95LXRlc3Q=.1","serviceName":"autotest-deploy-test","startTime":1669824000000}
                <<<<EOF
                """;
        File file = new File("D://a.txt");
        FileUtil.writeString(text, file, StandardCharsets.UTF_8);
        //第一步：设置响应类型
        response.setContentType("application/force-download");//应用程序强制下载
        //第二步：设置响应头，对文件进行url编码
        String fileName = URLEncoder.encode(file.getName(), StandardCharsets.UTF_8);
        response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
        ServletOutputStream out = response.getOutputStream();
        FileUtil.writeToStream(file, out);
    }
}
